<html>
<head><meta charset="utf-8"><title>IDE resilience · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html">IDE resilience</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160855056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/160855056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#160855056">(Mar 15 2019 at 08:14)</a>:</h4>
<p>An interesting example illustrating the difference between compiler and IDE requirements in terms of error handling:</p>
<div class="codehilite"><pre><span></span>macro_rules! foo {
    ($($tt:tt)*) =&gt; { foo!($($tt)*, $($tt)*); }
}

foo!(KABOOM);

fn main() {}
</pre></div>


<p>Here, rustc just dies with OOM, and that is sort of expected behavior. An explicit error message would be better, but this is a nice-to-have, not a requirement. </p>
<p>IDE, otoh, has to handle this case gracefully, for two reasons:</p>
<ul>
<li>it is a long-lived process which you can't just restart on OOM easily</li>
<li>IDE works with incomplete code, so it has much higher chance to encounter cases like above</li>
</ul>



<a name="163868461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163868461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163868461">(Apr 21 2019 at 21:32)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="216201">@Edwin Cheng</span> this might actually be a fun test-case!</p>



<a name="163868541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163868541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163868541">(Apr 21 2019 at 21:34)</a>:</h4>
<p>Yeah, here is another case : <br>
<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=839b39d24d1ba81ae911cad8ccb8833f" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=839b39d24d1ba81ae911cad8ccb8833f">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=839b39d24d1ba81ae911cad8ccb8833f</a></p>



<a name="163868859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163868859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163868859">(Apr 21 2019 at 21:42)</a>:</h4>
<p>I wonder how we should handle this in salsa?</p>
<p>If I weren't using salsa, I would implement some kind of a "fuel" system, which bounds not only the depth, but also the width of the expansion.</p>
<p>(random realization: "fuel" idea is deeper than I thought: it's exactly the device we use to turn arbitrary recursive function into a primitive recursive one)</p>
<p>However doing fuel in salsa is hard: if you just add it as a parameter, you loose incrementality... Perhaps we should a query for "deeply" expanding the macros, which internally repeatedly runs non-salsa fuel based shallow expansion?</p>



<a name="163868997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163868997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163868997">(Apr 21 2019 at 21:46)</a>:</h4>
<p>So do you mean we  should add a separate salsa database about current <code>execute context</code> ?</p>



<a name="163869021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869021">(Apr 21 2019 at 21:47)</a>:</h4>
<p>Probably no</p>



<a name="163869068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869068">(Apr 21 2019 at 21:48)</a>:</h4>
<p>though, trough to be told, I don't have a clear idea about this</p>



<a name="163869072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869072">(Apr 21 2019 at 21:48)</a>:</h4>
<p>So currently we have a query which expands a single macro</p>



<a name="163869077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869077">(Apr 21 2019 at 21:48)</a>:</h4>
<p>if in the result there's another macro invocation, we'll call the query again, and again, and again, etc</p>



<a name="163869091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869091">(Apr 21 2019 at 21:49)</a>:</h4>
<p>Adding stack depth to such a query would work</p>



<a name="163869094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869094">(Apr 21 2019 at 21:49)</a>:</h4>
<p>Adding fuel wouldn't</p>



<a name="163869097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869097">(Apr 21 2019 at 21:49)</a>:</h4>
<p>So, I wonder if we can implement fuel <em>outside</em> of the queries?</p>



<a name="163869148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869148">(Apr 21 2019 at 21:50)</a>:</h4>
<p>Hm, perhaps we should just add some counter to <code>DefCollector</code>?</p>



<a name="163869150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869150">(Apr 21 2019 at 21:50)</a>:</h4>
<p>I did do that</p>



<a name="163869153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869153">(Apr 21 2019 at 21:50)</a>:</h4>
<p>For depth, IIRC</p>



<a name="163869155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869155">(Apr 21 2019 at 21:50)</a>:</h4>
<p>but we can have a similar counter for width</p>



<a name="163869156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869156">(Apr 21 2019 at 21:50)</a>:</h4>
<p>But the problem is we have to send an empty result in salsa</p>



<a name="163869171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869171">(Apr 21 2019 at 21:51)</a>:</h4>
<p>Why "empty result" is a problem?</p>



<a name="163869172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869172">(Apr 21 2019 at 21:51)</a>:</h4>
<p>Only bypass it in <code>DefCollector</code> would not work</p>



<a name="163869178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869178">(Apr 21 2019 at 21:51)</a>:</h4>
<p>we cal always generate an empty file or something like that?</p>



<a name="163869227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869227">(Apr 21 2019 at 21:52)</a>:</h4>
<p>Because another code  will query salsa for that macro again.</p>



<a name="163869243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869243">(Apr 21 2019 at 21:53)</a>:</h4>
<p>Hm, could we store a list of "poisoned" macro calls in <code>CrateDefMap</code>?</p>



<a name="163869249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869249">(Apr 21 2019 at 21:53)</a>:</h4>
<p>when other code tries to construct MacroCallId for expansion, it'll check if it is poisoned in CrateDefMap</p>



<a name="163869301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869301">(Apr 21 2019 at 21:54)</a>:</h4>
<p>Hm, another though: what if we have stupid static fuel, which just restricts the maximum length of macro call to 65536 tokens?</p>



<a name="163869322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869322">(Apr 21 2019 at 21:55)</a>:</h4>
<p>That is, I think, to hit diverging behavior, we either need big depth (which is checkable by adding depth to MacroCallLoc), or wide macro invocations (which is checkable on each invocation).</p>



<a name="163869374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869374">(Apr 21 2019 at 21:56)</a>:</h4>
<p>I like both idea.</p>



<a name="163869378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869378">(Apr 21 2019 at 21:57)</a>:</h4>
<p>I'd probably started with static width: seems easier to impl, b/c we don't have to store anything</p>



<a name="163869437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869437">(Apr 21 2019 at 21:58)</a>:</h4>
<p>Yeah, i will do it tmr. (Here is 6:00 am now :) )</p>



<a name="163869448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869448">(Apr 21 2019 at 21:58)</a>:</h4>
<p>[Out of Topic] have you see <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1188" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1188">https://github.com/rust-analyzer/rust-analyzer/issues/1188</a> ?</p>



<a name="163869538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869538">(Apr 21 2019 at 22:01)</a>:</h4>
<p>Seen, but haven't looked into yat</p>



<a name="163869542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/IDE%20resilience/near/163869542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/IDE.20resilience.html#163869542">(Apr 21 2019 at 22:02)</a>:</h4>
<p>Bye!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>